WWL.checkbox = function ( name, value, checked )
{
	var check = new WWL ( 'checkbox', name );

	check._checked = !! checked;
	check._value = value;
	check._name = name;

	check.cbacks = {
		'click': null
	};

	check.to_string = function ( html )
	{
		if ( ! html ) html = '';
		return '<div id="wwl:checkbox:' + name + '" class="checkbox ' + ( check._checked ? 'checked' : '' ) + '" onclick="WWL.checkbox.click(\'' + name + '\')">' +
			html +
			'</div>';
	};

	check.get_value = function ()
	{
		if ( check._checked ) return check._value;
		return false;
	};

	check.set_value = function ( value )
	{
		check._value = value;
	};
	
	return check;
};

WWL.checkbox.click = function ( name )
{
	var inst = WWL.get_instance ( 'checkbox', name );
	inst._checked = ! inst._checked;

	var chk = $ ( 'wwl:checkbox:' + inst.name );
	if ( inst._checked )
		liwe.dom.add_class ( chk, 'checked' );
	else
		liwe.dom.del_class ( chk, 'checked' );

	if ( inst.cbacks [ 'click' ] )
		inst.cbacks [ 'click' ] ( inst._checked );
};
